import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CategoryProjectVO, CategoryProjectForm, CategoryProjectQuery } from '@/api/nav/categoryProject/types';

/**
 * 查询分类项目关联列表
 * @param query
 * @returns {*}
 */

export const listCategoryProject = (query?: CategoryProjectQuery): AxiosPromise<CategoryProjectVO[]> => {
  return request({
    url: '/nav/categoryProject/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询分类项目关联详细
 * @param id
 */
export const getCategoryProject = (id: string | number): AxiosPromise<CategoryProjectVO> => {
  return request({
    url: '/nav/categoryProject/' + id,
    method: 'get'
  });
};

/**
 * 新增分类项目关联
 * @param data
 */
export const addCategoryProject = (data: CategoryProjectForm) => {
  return request({
    url: '/nav/categoryProject',
    method: 'post',
    data: data
  });
};

/**
 * 修改分类项目关联
 * @param data
 */
export const updateCategoryProject = (data: CategoryProjectForm) => {
  return request({
    url: '/nav/categoryProject',
    method: 'put',
    data: data
  });
};

/**
 * 删除分类项目关联
 * @param id
 */
export const delCategoryProject = (id: string | number | Array<string | number>) => {
  return request({
    url: '/nav/categoryProject/' + id,
    method: 'delete'
  });
};
